

var data={}


function define(obj,key,val) {
    
    var property = Object.getOwnPropertyDescriptor(obj, key);
    var getter = property && property.get;
    var setter = property && property.set;

    console.log('property-->',property);
    console.log('getter-->',getter);
    
    
    Object.defineProperty(obj,"arr",{
        enumerable: true,
        configurable: true,
        get(){

            var value = getter ? getter.call(obj) : val;

            console.log('get--->',value);
            
            return value
        },

        set(newVal){
            
            console.log('setter--->',setter);

            if (setter) {
                setter.call(obj, newVal);
            } else {
                val = newVal;
            }

            console.log('arr--newVal',newVal);
            
        }
    })

}

define(data,"arr",5)

console.log('data',data.arr);
data.arr=6666
console.log('data',data.arr);

